<?php

// Menu
define("EW_MENUBAR_CLASSNAME", "ewMenuBarVertical", TRUE);
define("EW_MENUBAR_SUBMENU_CLASSNAME", "", TRUE);
?>
<?php

// MenuItem Adding event
function MenuItem_Adding(&$Item) {

	//var_dump($Item);
	// Return FALSE if menu item not allowed

	return TRUE;
}
?>
<!-- Begin Main Menu -->
<?php

// Generate all menu items
$RootMenu = new cMenu("RootMenu");
$RootMenu->IsRoot = TRUE;
getMenu('NULL');


$tableobject=R::findOne("portal_objects","name = ? ",array("portal_logins"));
$tablemenu=R::findOne("portal_menu","objectId = ? ",array($tableobject->id));

//$tablemenu->id

$RootMenu->AddMenuItem(-2, $Language->Phrase("ChangePwd"), "?action=changepwd", -1, "", IsLoggedIn() && !IsSysAdmin(),"password");
$RootMenu->AddMenuItem(-1, $Language->Phrase("Logout"), "?action=logout", -1, "", IsLoggedIn(),"logout");

$RootMenu->AddMenuItem(-1, $Language->Phrase("Login"), "?action=login", -1, "", !IsLoggedIn() && substr(@$_SERVER["URL"], -1 * strlen("login")) <> "login","login");
$RootMenu->Render();
?>



<script type="text/javascript">



$(document).ready(function(){

	$('#cssmenu > ul > li ul').each(function(index, element){
		// var count = $(element).find('li').length;
		//  var content = '<span class="cnt">' + count + '</span>';
		// $(element).closest('li').children('a').append(content);
		});


	$('#cssmenu ul ul li:odd').addClass('odd');
	$('#cssmenu ul ul li:even').addClass('even');



	var onMyEvent = function(){
		//alert("ok");
		  var checkElement = $(this).next();

		  $('#cssmenu li').removeClass('active');
		  $(this).closest('li').addClass('active'); 

		  if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
		    $(this).closest('li').removeClass('active');
		    checkElement.slideUp('normal');
		  }
		  if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		    $('#cssmenu ul ul:visible').slideUp('normal');
		    checkElement.slideDown('normal');
		  }

		  if($(this).closest('li').find('ul').children().length == 0) {
		    return true;
		  } else {
		    return false; 
		  }
	
	}
	
	$('#cssmenu > ul > li > a').click(onMyEvent);

//	$('a[href^="?table=<?=getParameter("table")?>"]').parent().parent().parent().children().first().hide();

	$('a[href^="?table=<?=getParameter("table")?>"]').parent().parent().parent().children().first().click();


	});


</script>
<style>
.menu_center{
<?php if ($lang!="ar") {?>
  padding-bottom: 0;
    padding-top: 10px;
	<?php } ?>
}
.sf-menu li{
float:<?php echo $left; ?>;
}
.child {
text-align: <?php echo $left; ?>;
}
</style>
<?php getAvailableLanguages(); ?>
<!-- End Main Menu -->